package main

import (
	"fmt"
	"sync"
	"time"
)

var (
	testMap = make(map[int]int, 10)
	lock    sync.Mutex
	//testMap sync.Map
)

func main() {
	for i := 1; i < 100; i++ {
		go testNums(i)
	}

	time.Sleep(time.Second * 5)
	//lock.Lock()
	for key, val := range testMap {
		fmt.Printf("key:%v val:%v\n", key, val)
	}
	//lock.Unlock()
}

func testNums(num int) {
	lock.Lock()
	val := num * num
	testMap[num] = val
	lock.Unlock()
	//testMap.Store(num, val)
}
